package com.ruoyi.marketing.service.impl;


import java.util.List;

import com.ruoyi.marketing.domain.MarketingAward;
import com.ruoyi.marketing.domain.MarketingTask;
import com.ruoyi.marketing.service.IMarketingAwardService;
import com.ruoyi.marketing.service.IMarketingTaskService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.marketing.mapper.AwardDetailMapper;
import com.ruoyi.marketing.domain.AwardDetail;
import com.ruoyi.marketing.service.IAwardDetailService;

/**
 * 活动奖励明细Service业务层处理
 *
 * @author hao
 * @date 2023-01-31
 */
@Service
public class AwardDetailServiceImpl extends ServiceImpl<AwardDetailMapper, AwardDetail> implements IAwardDetailService {
    @Autowired // 任务
    private IMarketingTaskService marketingTaskService;
    @Autowired // 奖励
    private IMarketingAwardService marketingAwardService;


    @Override
    public List<AwardDetail> selectAwardDetailList() {
        List<AwardDetail> list = list();
        for (AwardDetail awardDetail : list) {
            //  查询任务对象
            MarketingTask taskServiceById = marketingTaskService.getById(awardDetail.getTaskId());
            if (taskServiceById != null) {
                awardDetail.setTask(taskServiceById);
            }
            //  查询奖励对象
            MarketingAward awardServiceById = marketingAwardService.getById(awardDetail.getAwardId());
            if (awardServiceById != null) {
                awardDetail.setMarketingAward(awardServiceById);
            }
        }
        return list;
    }
}
